#!/usr/bin/env bash
## check env & package
command -v quasar >/dev/null 2>&1 || { echo >&2 "quasar uninstall? try: $ cnpm install -g cordova"; exit; }
sed -i "" "s/global.IS_ANDROID = true/global.IS_ANDROID = false/g"  ./src/gloabal.js
quasar build
if [[ $? != "0" ]]; then
    echo "⚠️  打包资源异常"
    exit 1
fi

cp ./src/root.txt  ./dist/


## transfer resouce
scp -r ./dist/* root@himygirl.cn:/usr/share/nginx/cweb

# deploydir="web-deploy"
# cd ${deploydir}/
# if [[ $? != "0" ]]; then
#     echo "⚠️  缺少["${deploydir}"]目录资源"
#     exit 1
# fi

##
# 暂定直接copy到appSever中

# rm -rf /Users/mac/Desktop/application-app/work-personal/modules/mygirl-c-app/src/main/resources/static/static/*
# cp -r ../dist/* /Users/mac/Desktop/application-app/work-personal/modules/mygirl-c-app/src/main/resources/static/static



# cd ..
# echo "start compresss->"
# tar czvf ${deploydir}.tar.gz ./${deploydir}
# echo "compresss Successed!"
# echo "you need to push the file of["${deploydir}.tar.gz"] to your server" 
# echo "And then decompression"
# echo "Example:"
# echo "$ cd ./"${deploydir}
# echo "$ ./start.sh "